<template>
	<view class="content">
		<view class="" style="padding: 0 22rpx;">
			<view class="bgWhite radius6    mt12 info">
				<view class="justify-between align-center">
					<image :src="detail.goods_img" mode=""></image>
					<view class="flex1 flex-col justify-around" style="height: 180rpx;">
						<view class="name ft16 clamp2">{{detail.goods_name}}</view>
						<view class="">
							<view class="stages">
								¥{{detail.show_price}}
							</view>
							<view class="justify-between align-center">
								<text class="money">¥ {{detail.goods_price}}</text>
								<view class="count">
									数量：{{detail.num}}
								</view>
							</view>
						</view>
					</view>
				</view>
				<view class="remark mt16 justify-between align-center">
					<text>订单备注</text>
					{{detail.remark}}
				</view>
			</view>
			<view class="bgWhite radius6   mb20 mt15  inlineList  ">
				<view class="timeBox justify-between align-center " style="margin-bottom: 0;">
					<view class="">商品金额</view> <text v-if="detail.goods_price">￥{{detail.goods_price}}</text>
				</view>
			</view>
			<view class="bgWhite radius6   mb20 mt15 plr15 ptb15   "  v-if="(detail.hetong&&detail.hetong.length)||(detail.xianshang_hetong)">
				<view class="ft18 mb10" style="font-weight: 600;">
					合同信息
				</view>
				<view class="" v-if="detail.mingxi">
					明细：{{detail.mingxi}}
				</view>
				<view class="align-center flex-wrap justify-start" v-if="detail.hetong&&detail.hetong.length" >
					<view class="mr10 mt5 posRelative" v-for="(i,n) in detail.hetong" :key="n" >
						<image style="width: 200rpx;height: 200rpx;border-radius: 15rpx;"  :src="i" mode=""></image>
						
					</view>
				</view>
				<view v-if="detail.xianshang_hetong" class="align-center mt10 w100 justify-between " style="color: #3F7865;" @click="showwatch">
				查看合同文件	 <uv-icon name="arrow-right"></uv-icon>
				</view>
				
			</view>
			<view class="bgWhite radius6   mb20 mt15  timeLineList  ">
				<view class="justify-between align-center header">
					<text class="title">分期详情</text>
					<text>剩余{{detail.remain}}期</text>
				</view>
				<view class="pt20">
					<view class="justify-between processitem" v-for="(i,n) in detail.pay_Log" :key="n">
						<view class="" style="text-align: right;">
							<view class="mb10">
								第{{i.numbers}}期
							</view>
							<text class="">{{i.time}}</text>
						</view>
						<view class="circle posRelative align-center justify-center  ">
							<view class="">

							</view>
						</view>
						<view class="flex1">
							<view class="justify-between">
								<view class="money">
									{{i.order_amount_total}}
								</view>
								<view class="status">
									{{i.status_info}}
								</view>
							</view>
							<text class="desc">{{i.info}}</text>
							<view class="mt15 align-start">
								支付凭证:<image class="ml20" :src="i.images" @click="preview(i.images)" style="width: 200rpx;height: 200rpx;border-radius: 15rpx;" ></image>
							</view>
						</view>
					</view>
				</view>
			</view>

		</view>
		<view class="" style="height: 130rpx;">

		</view>
		<view class=" bgWhite paybtn" v-if="status=='1'">
          
            <view class="justify-between align-center">
            
                <view @click="cancelOrder" class="onlinePay">取消订单</view>
            </view>
          
            
        </view>

	</view>
</template>

<script>
	export default {
		data() {
			return {


				detail: {},
				status:"",
				id: ""
			}
		},

		onLoad(opt) {
			if (opt.id) this.id = opt.id
			if (opt.status) this.status = opt.status
			this.getDetail()
			// this.$refs.choseCoupon.open()
		},
		methods: {
			cancelOrder(){
				let vm =this
					uni.showModal({
						content:'确定要取消该订单吗',
						success:function(res){
							if(res.confirm){
										
									vm.$api.ordercancel({id:vm.id}).then(res=>{
										vm.$utils.msg('操作成功')
										vm.getDetail()
									})
							}
						}
					})
			},
			preview(url){
				uni.previewImage({
					urls:[url]
				})
			},
			getDetail() {
				this.$api.orderinfo({
					id: this.id
				}).then(res => {
					console.log(res)
					this.detail = res.data
				})

			},
			showwatch(){
				
				uni.downloadFile({
					url: this.detail.xianshang_hetong,
					success: function(res) {
						var filePath = res.tempFilePath;
						uni.openDocument({
							filePath: filePath,
							showMenu: true,
							success: function(res) {
								uni.hideLoading()
								console.log('Document opened successfully');
							},
							fail: function(err) {
								console.log('Failed to open document', err);
							}
						});
					},
					fail: function(res) {
						console.log('Download failed', res);
					}
				});
			}


		}
	}
</script>
<style scoped lang="scss">
	.notice {
		padding: 26rpx 48rpx;
		background: #FCF3EE;
		border: 2rpx solid #F3D6C6;
		font-size: 28rpx;
		color: #F3915B;

		image {
			margin-left: 86rpx;
			width: 60rpx;
		}
	}

	.paybtn {

		position: fixed;
		bottom: 0;
		width: 100%;
		padding: 30rpx;
		z-index: 999;
		background-color: #fff;

		.onlinePay {
			width: 100%;
			height: 88rpx;
			background: #FFFFFF;
			border-radius: 12rpx;
			color: #fff;
			font-size: 34rpx;
			background: #49806F;
			line-height: 88rpx;


			text-align: center;
		}

		.freebtn {
			text {
				color: #FF9012;
			}
		}

	}

	.moduleTitle {
		font-weight: 600;
		color: #000000;
		line-height: 54rpx;
		font-size: 32rpx;
		margin: 30rpx 0 10rpx;
	}

	.swiper {
		image {
			width: 100%;
			height: 300rpx;
		}
	}

	.info {
		padding: 18rpx 14rpx 27rpx 18rpx;

		image {
			width: 237rpx;
			height: 173rpx;
			border-radius: 8rpx;
			margin-right: 27rpx;

		}

		.name {
			color: #222;
			font-weight: bold;
			font-size: 30rpx;
		}

		.address {
			color: #9F9F9F;
		}
	}

	.timeBox {
		color: #999;
		font-size: 32rpx;
		margin-bottom: 40rpx;

		text {
			font-weight: 500;
			font-size: 32rpx;
			color: #333333;
		}
	}

	.artItem {
		box-shadow: 0rpx 0rpx 12rpx 0rpx rgba(0, 0, 0, 0.0612);
		font-size: 24rpx;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		margin-bottom: 36rpx;
		font-size: 24rpx;
		color: #666666;

		.left {
			width: 224rpx;
			height: 180rpx;
			background: #FFF2F2;
			border-radius: 12rpx 12rpx 12rpx 12rpx;
		}

		.desc {
			font-weight: 600;
			font-size: 32rpx;
			color: #E6220A;
		}

		.name {
			font-weight: 600;
			font-size: 64rpx;
			color: #E6220A;
		}
	}

	.service {
		width: 140rpx;
		height: 66rpx;
		background: #E6220A;
		color: #fff;
		text-align: center;
		font-size: 32rpx;
		line-height: 66rpx;
		border-radius: 60rpx 60rpx 60rpx 60rpx;
		margin-right: 20rpx;
	}

	.stages {
		border-radius: 5rpx;
		border: 1px solid #3F7865;
		color: #3F7865;
		font-size: 22rpx;
		display: inline-block;
		line-height: 22rpx;
		margin-bottom: 18rpx;
		padding: 5rpx 8rpx;
	}

	.count {
		font-weight: 400;
		font-size: 24rpx;
		color: #999999;
	}

	.inlineList {
		padding: 26rpx 35rpx 40rpx 25rpx;
	}

	.timeLineList {
		padding: 32rpx 27rpx;

		.header {
			font-weight: 400;
			font-size: 30rpx;
			line-height: 30rpx;
			color: #888888;
			border-bottom: 1rpx solid #EFEFEF;
			padding-bottom: 33rpx;

			.title {
				color: #333333;
			}
		}
	}

	.processitem {
		margin-bottom: 76rpx;
		font-size: 24rpx;
		color: #333333;
		line-height: 1;

		.money {
			font-weight: 500;
			font-size: 30rpx;
			color: #111111;
			margin-bottom: 26rpx;
		}

		.desc {
			font-weight: 400;
			font-size: 26rpx;
			color: #888888;
		}
	}

	.pt20 {
		padding-top: 40rpx;
	}

	.circle {
		background: #3F7865;
		width: 25rpx;
		height: 25rpx;
		border-radius: 50%;
		margin: 5rpx 30rpx 0;
		z-index: 99;

		view {
			width: 10rpx;
			height: 10rpx;
			border-radius: 50%;
			position: relative;
			background: #fff;
			z-index: 99;
		}
	}

	.circle::after {
		clear: both;
		content: '';
		position: absolute;
		background-color: #D6D6D6;
		height: 360rpx;
		width: 2rpx;
		top: 25rpx;
		z-index: 9;
	}

	.remark {
		background: #F5F5F7;
		border-radius: 8rpx;
		height: 70rpx;
		padding: 0 20rpx;
		margin-top: 32rpx;
	}
</style>